
import subprocess

import time

import logging

logging.basicConfig(level = logging.INFO,format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s')

logger = logging.getLogger(__name__)

def pppd():

    cmd = ["bash", "/etc/ppp/peers/quectel-pppd.sh"]

    completed_process = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)

    logger.info("completed_process.returncode: {}".format(completed_process.returncode))

    if completed_process.returncode == 0:
        # 获取命令的标准输出结果
        output = completed_process.stdout

        print(output)

        time.sleep(4)

        pppd()

    else:

        error_message = completed_process.stderr
        print(f"Command execution failed: {error_message}")



if __name__ == "__main__":

    pppd()